import requests

API_KEY = 'your_api_key'  # 在2captcha网站上申请API Key


def solve_captcha(image_url):
    # 向2Captcha发送验证码图片URL
    response = requests.post('http://2captcha.com/in.php', data={
        'key': API_KEY,
        'method': 'get',
        'body': image_url,
    })

    # 获取验证码ID
    captcha_id = response.text.split('|')[1]

    # 获取验证码结果
    result = requests.get(f'http://2captcha.com/res.php?key={API_KEY}&action=get&id={captcha_id}')
    return result.text.split()[1]  # 返回验证码识别结果


captcha_result = solve_captcha('https://jwgl.nxu.edu.cn/captcha/image.action?t=1744258927002')
print(f"验证码识别结果: {captcha_result}")